import Router from 'next/router'

export default () => {
  Router.events.on('routeChangeStart', (...args) => {
    console.log('1.routeChangeStart ==> 路由开始变化，参数为：', ...args);
  })
  Router.events.on('routeChangeComplete', (...args) => {
    console.log('2.routeChangeComplete ==> 路由变化完成，参数为：', ...args);
  })
  Router.events.on('beforeHistoryChange', (...args) => {
    console.log('3.beforeHistoryChange ==> 在改变浏览器 history 之前触发，参数为：', ...args);
  })
  // 404 找不到路由页面不算错误
  Router.events.on('routeChangeError', (...args) => {
    console.log('4.routeChangeError ==> 路由跳转发生错误时触发，参数为：', ...args);
  })

  // Hash
  Router.events.on('hashChangeStart', (...args) => {
    console.log('5.hashChangeStart ==> Hash 模式开始跳转，参数为：', ...args);
  })
  Router.events.on('hashChangeComplete', (...args) => {
    console.log('6.hashChangeComplete ==> Hash 模式跳转完成，参数为：', ...args);
  })
  return <h2>hook</h2>
}